package com.example.zdravaprehrana;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.Menu;
import android.view.View;


public class MainActivity extends Activity {
	
	private static final int ex = 1;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	public void klikPrehrana(View v){
		Intent i = new Intent(MainActivity.this, PrehranaActivity.class);
		startActivity(i);
	}
	
	public void klikJedilnik(View v){
		Intent i = new Intent(MainActivity.this, JedilnikActivity.class);
		startActivity(i);
	}
	
	public void klikPodatki(View v){
		Intent i = new Intent(MainActivity.this, PodatkiActivity.class);
		startActivity(i);
	}
	
	
	@Override
	protected Dialog onCreateDialog(int id){
		AlertDialog.Builder builder;
		switch(id){
		case ex:
			builder=new AlertDialog.Builder(this);
			builder.setMessage("Izhod?")
			.setCancelable(false)
			.setPositiveButton("Da", new DialogInterface.OnClickListener(){
				@Override
				public void onClick(DialogInterface dialog, int id){
					MainActivity.this.setResult(RESULT_CANCELED);
					MainActivity.this.finish();
				}
			})
			.setNegativeButton("Ne", new DialogInterface.OnClickListener(){
				@Override
				public void onClick(DialogInterface dialog, int id){
					MainActivity.this.setResult(RESULT_OK);
					dialog.cancel();
				}
			});
			return builder.create();
		}
	return null;
	}
	public void klikIzhod(View view){
			showDialog(ex);
	}
	
}
